import React from 'react'
import { Navigate } from 'react-router-dom'
const withRouter = (Wrapped) => {
  return class extends React.Component {
    render() {
      return (
        <>
          {window.localStorage.getItem('token') ? (
            <Wrapped {...this.props}></Wrapped>
          ) : (
            <Navigate to={'/login'}></Navigate>
          )}
        </>
      )
    }
  }
}

export default withRouter
